package thead;
/*
有三个线程，分别只能打印A，B和C
要求按顺序打印ABC，打印10次
输出示例：
ABC
ABC
ABC
ABC
ABC
ABC
ABC
ABC
ABC
ABC
 */
public class practice4_2 {
    private static final Object lock = new Object();
    public static void main(String[] args) throws InterruptedException {
        for(int i = 0;i < 10;i++) {
            Thread A = new Thread(() ->{
                synchronized(lock) {
                    System.out.print('A');
                }
            });
            Thread B = new Thread(() ->{
                synchronized(lock) {
                    System.out.print('B');
                }
            });
            Thread C = new Thread(() ->{
                synchronized(lock) {
                    System.out.println('C');
                }
            });
            A.start();
            A.join();
            B.start();
            B.join();
            C.start();
            C.join();
        }
        System.out.println("Ok");
    }
}
